home *** CD-ROM | disk | FTP | other *** search
/ Software of the Month Club (Business) 1997 July / Software of the Month Club - Business (Volume 239) (July 1997).iso / pc / code / d.dxr / 00009_Bass Code.ls < prev    next >
Encoding:
Text File  |  1996-02-15  |  11.8 KB  |  362 lines

  1. global sSTRINGSTART, sBENDSTRING, gHookPoints, gNumHooks, stringPoints, string2Points, MsetPointIterations, gBASSSTRINGLENBASE, HARP, TIGO, HORN, DRUM, CHIME, BASS, sPALETTE, gObjects, gOBJECTSD, gWorld, gPuppetlines, sQTCharSprite, gNextEnvLetter, gMIDIPlayTRUE, gInitalized, noteObjs, windowsMIDIXObj, xNAVXOBJ, xCURXOBJ, gCPU, gFileSep, gRootPath, gHDpath, gXobjs, gXOBJPath, gCDpath, gCDName
  2.  
  3. on playChaoticBASS OBJref
  4.   set OBj to getaProp(gObjects, OBJref)
  5.   PlayNoteFromHitMap(#BASS)
  6. end
  7.  
  8. on PlayBassNote Pitchnote, Lengthnote
  9.   set note to 65 - ((Pitchnote - 70) / 6)
  10.   if note > 65 then
  11.     set note to 65
  12.   else
  13.     if note < 35 then
  14.       set note to 35
  15.     end if
  16.   end if
  17.   noteOn(#BASS, note, 127)
  18.   if Lengthnote > 120 then
  19.     set Lengthnote to 120
  20.   else
  21.     if Lengthnote < 10 then
  22.       set Lengthnote to 10
  23.     end if
  24.   end if
  25.   set noteOnTime to the ticks
  26.   repeat while the ticks < (noteOnTime + Lengthnote)
  27.     CursorandUpdate()
  28.   end repeat
  29.   noteOff(#BASS, note)
  30. end
  31.  
  32. on CheckStringClick H, V, Slopelist
  33.   set C to count(Slopelist)
  34.   repeat with X = 1 to C
  35.     set aLine to getaProp(getaProp(getaProp(gObjects, getAt(Slopelist, X)), #SpriteProp), #rect)
  36.     if inside(point(H, V), aLine) then
  37.       ONslope(point(H, V), aLine)
  38.     end if
  39.     if ONslope(point(H, V), aLine) then
  40.       set StringNum to getAt(Slopelist, X)
  41.       return StringNum
  42.     end if
  43.   end repeat
  44. end
  45.  
  46. on CalSlope x1, y1, x2, y2
  47.   set SUB to abs(x1 - x2)
  48.   if SUB <> 0 then
  49.     return integer(abs(y1 - y2) / float(SUB))
  50.   else
  51.     return 0
  52.   end if
  53. end
  54.  
  55. on ONslope aPoint, aLine
  56.   set orginPointX to the left of aLine
  57.   set orginPointY to the top of aLine
  58.   set Lineslope to CalSlope(orginPointX, orginPointY, the right of aLine, the bottom of aLine)
  59.   if Lineslope = 0 then
  60.     return 0
  61.   else
  62.     set PointSlope to CalSlope(orginPointX, orginPointY, the locH of aPoint, the locV of aPoint)
  63.     if Lineslope = PointSlope then
  64.       return 1
  65.     end if
  66.   end if
  67. end
  68.  
  69. on UnHookBass Stringref, HookNum
  70.   set OBj to getaProp(gObjects, Stringref)
  71.   set hookpoint to getAt(getaProp(getaProp(gObjects, #BASS), #HookPoints), HookNum)
  72.   setAt(getaProp(getaProp(gObjects, #BASS), #Hooked), HookNum, 0)
  73.   MakeDynamic(#BASS, #Hooked, getaProp(getaProp(gObjects, #BASS), #Hooked))
  74.   bassString(Stringref, the locH of hookpoint, the locV of hookpoint)
  75. end
  76.  
  77. on bassString OBJref, mH, mV
  78.   set BASSObj to getaProp(gObjects, #BASS)
  79.   set OBj to getaProp(gObjects, OBJref)
  80.   set Fake to getaProp(gObjects, getaProp(OBj, #Attach))
  81.   set OBJSprite to getaProp(OBj, #SpriteNum)
  82.   set FakeSprite to getaProp(Fake, #SpriteNum)
  83.   set ObjL to the left of sprite getaProp(OBj, #SpriteNum)
  84.   set ObjT to the top of sprite getaProp(OBj, #SpriteNum)
  85.   set FakeR to the right of sprite getaProp(Fake, #SpriteNum)
  86.   set FakeB to the bottom of sprite getaProp(Fake, #SpriteNum)
  87.   repeat while the mouseDown
  88.     UpdateBassStrings(OBj, OBJSprite, ObjL, ObjT, mH, mV)
  89.     UpdateBassStrings(Fake, FakeSprite, mH, mV, FakeR, FakeB)
  90.     CursorandUpdate()
  91.     set mH to the mouseH
  92.     set mV to the mouseV
  93.   end repeat
  94.   set Hook to CheckinHookRect(mH, mV)
  95.   if Hook <> #false then
  96.     if getAt(getaProp(BASSObj, #Hooked), Hook) = 0 then
  97.       setAt(getaProp(BASSObj, #Hooked), Hook, OBJref)
  98.       set aPoint to getAt(getaProp(BASSObj, #HookPoints), Hook)
  99.       set newH to the locH of aPoint
  100.       set newV to the locV of aPoint
  101.       UpdateBassStrings(OBj, OBJSprite, ObjL, ObjT, newH, newV)
  102.       UpdateBassStrings(Fake, FakeSprite, newH, newV, FakeR, FakeB)
  103.       CursorandUpdate()
  104.     else
  105.       set Hook to #false
  106.     end if
  107.   end if
  108.   if Hook = #false then
  109.     UpdateBassStrings(OBj, OBJSprite, ObjL, ObjT, FakeR + 3, FakeB)
  110.     UpdateBassStrings(Fake, FakeSprite, FakeR + 3, FakeB, FakeR, FakeB)
  111.     CursorandUpdate()
  112.   end if
  113.   DynamicLOCRECT(OBJref)
  114.   DynamicLOCRECT(getaProp(OBj, #Attach))
  115. end
  116.  
  117. on UpdateBassStrings OBj, Snum, left, top, right, bottom
  118.   set lean to FindLean(left, top, right, bottom)
  119.   setaProp(OBj, #DisplayState, lean)
  120.   set the castNum of sprite Snum to getaProp(getaProp(OBj, #cast), getaProp(OBj, #DisplayState))
  121.   set the rect of sprite Snum to rect(left, top, right, bottom)
  122. end
  123.  
  124. on FindLean left, top, right, bottom
  125.   if top > bottom then
  126.     if left > right then
  127.       return #right
  128.     else
  129.       return #left
  130.     end if
  131.   else
  132.     if left > right then
  133.       return #left
  134.     else
  135.       return #right
  136.     end if
  137.   end if
  138. end
  139.  
  140. on constrainNote note
  141.   if note > 100 then
  142.     set note to (note / 10) + 30
  143.   end if
  144.   if note < 30 then
  145.     set note to note + 30
  146.   end if
  147.   if note > 60 then
  148.     set note to note - 30
  149.   end if
  150.   return note
  151. end
  152.  
  153. on CheckhookRect NUM
  154.   set Hookref to getAt(getaProp(getaProp(gObjects, #BASS), #Hooked), NUM)
  155.   if Hookref <> 0 then
  156.     return Hookref
  157.   else
  158.     return #false
  159.   end if
  160. end
  161.  
  162. on CheckinHookRect H, V
  163.   set C to count(getaProp(getaProp(gObjects, #BASS), #Hookrects))
  164.   repeat with NUM = 1 to C
  165.     if inside(point(H, V), getAt(getaProp(getaProp(gObjects, #BASS), #Hookrects), NUM)) then
  166.       return NUM
  167.     end if
  168.   end repeat
  169.   return #false
  170. end
  171.  
  172. on DoCheckLinePull OBJref
  173.   set H to the mouseH
  174.   set V to the mouseV
  175.   set HookedNum to CheckinHookRect(H, V)
  176.   if HookedNum <> #false then
  177.     set Hookedlines to CheckhookRect(HookedNum)
  178.     if Hookedlines <> #false then
  179.       UnhookLineMove(Hookedlines, HookedNum)
  180.     end if
  181.   else
  182.     set index to xCURXOBJ(mWhere, H, V)
  183.     if index > 0 then
  184.       MoveHookedLine(index)
  185.     end if
  186.   end if
  187. end
  188.  
  189. on CheckBassStringUP Snum, LineRef, H, V
  190.   set HookedNum to CheckinHookRect(H, V)
  191.   if HookedNum <> #false then
  192.     if CheckhookRect(HookedNum) = #false then
  193.       ShowNewHookedLines(HookedNum, LineRef)
  194.       CheckBassChaotic()
  195.     else
  196.       ResetBassLineStart(Snum, H, V)
  197.     end if
  198.   else
  199.     ResetBassLineStart(Snum, H, V)
  200.   end if
  201. end
  202.  
  203. on CheckBassChaotic
  204.   set Chaotic to 1
  205.   repeat with Snum in [5, 8, 9, 14, 16, 21]
  206.     if the visible of sprite Snum = 1 then
  207.       next repeat
  208.       next repeat
  209.     end if
  210.     set Chaotic to 0
  211.     exit repeat
  212.   end repeat
  213.   if Chaotic = 1 then
  214.     set BaseAnim to getaProp(gObjects, #BassToChaos)
  215.     playSound("D12strn.aif", #keyframeCast)
  216.     set the loc of sprite getaProp(BaseAnim, #SpriteNum) to getaProp(BaseAnim, #loc)
  217.     repeat with CastID in getaProp(getaProp(BaseAnim, #cast), #FrameData)
  218.       set the castNum of sprite getaProp(BaseAnim, #SpriteNum) to CastID
  219.       CursorandUpdate()
  220.     end repeat
  221.     UnLoadChoaticHitMap()
  222.     LoadChoaticHitMap(#BASS)
  223.     ChangeSpecialState(#BASS, #Chaotic)
  224.   end if
  225. end
  226.  
  227. on MoveHookedLine index
  228.   set lineclicked to getAt(getaProp(getaProp(getaProp(gObjects, #BASS), #SpecialChild), #nonChaotic), index)
  229.   set ClickOBJ to getaProp(gObjects, lineclicked)
  230.   set Snum to getaProp(ClickOBJ, #SpriteNum)
  231.   if the visible of sprite Snum = 1 then
  232.     set aTop to the top of sprite Snum
  233.     set aBottom to the bottom of sprite Snum
  234.     if the type of sprite Snum = 5 then
  235.       set aleft to the left of sprite Snum
  236.       set aRight to the right of sprite Snum
  237.     else
  238.       set aleft to the right of sprite Snum
  239.       set aRight to the left of sprite Snum
  240.     end if
  241.     set the visible of sprite Snum to 0
  242.     set returnLoc to LineMove(aleft, aTop, aRight, aBottom)
  243.     CheckBassStringUP(Snum, lineclicked, the locH of returnLoc, the locV of returnLoc)
  244.   end if
  245. end
  246.  
  247. on LineMove aleft, aTop, aRight, aBottom
  248.   set Fake1 to getaProp(gObjects, #BasslineFake1)
  249.   set Fake1Snum to getaProp(Fake1, #SpriteNum)
  250.   set Fake2 to getaProp(gObjects, #BasslineFake2)
  251.   set Fake2Snum to getaProp(Fake2, #SpriteNum)
  252.   repeat while the mouseDown
  253.     set H to the mouseH
  254.     set V to the mouseV
  255.     UpdateBassStrings(Fake1, Fake1Snum, aleft, aTop, H, V)
  256.     UpdateBassStrings(Fake2, Fake2Snum, H, V, aRight, aBottom)
  257.     updateStage()
  258.   end repeat
  259.   return point(H, V)
  260. end
  261.  
  262. on ValidLine line1, HookedNum
  263.   set aLine to value("#" & "Bassline" & line1 & HookedNum)
  264.   if voidp(getaProp(gObjects, aLine)) then
  265.     set aLine to value("#" & "Bassline" & HookedNum & line1)
  266.   end if
  267.   return aLine
  268. end
  269.  
  270. on UnhookLineMove Hookedlines, HookedNum
  271.   set Hookedlines to []
  272.   repeat with Link in [#BL, #BR, #T, 1, 2, 3, 4]
  273.     if Link <> HookedNum then
  274.       set TryLine to ValidLine(Link, HookedNum)
  275.       if the visible of sprite getaProp(getaProp(gObjects, TryLine), #SpriteNum) = 1 then
  276.         add(Hookedlines, TryLine)
  277.       end if
  278.     end if
  279.   end repeat
  280.   set Line1OBj to getaProp(gObjects, getAt(Hookedlines, 1))
  281.   set Line2OBj to getaProp(gObjects, getAt(Hookedlines, 2))
  282.   set S1 to getaProp(Line1OBj, #SpriteNum)
  283.   set S2 to getaProp(Line2OBj, #SpriteNum)
  284.   setAt(getaProp(getaProp(gObjects, #BASS), #Hooked), HookedNum, 0)
  285.   setaProp(getaProp(Line1OBj, #SpriteProp), #visible, 0)
  286.   setaProp(getaProp(Line2OBj, #SpriteProp), #visible, 0)
  287.   MakeDynamic(getAt(Hookedlines, 1), #State, #INVisible)
  288.   MakeDynamic(getAt(Hookedlines, 2), #State, #INVisible)
  289.   set line1char1 to char 9 of string(getAt(Hookedlines, 1))
  290.   set line1char2 to char 10 of string(getAt(Hookedlines, 1))
  291.   if line1char2 = "B" then
  292.     set line1char2 to char 10 to 11 of string(getAt(Hookedlines, 1))
  293.   end if
  294.   if line1char1 <> string(HookedNum) then
  295.     set line1 to line1char1
  296.   else
  297.     set line1 to line1char2
  298.   end if
  299.   set line2char1 to char 9 of string(getAt(Hookedlines, 2))
  300.   set line2char2 to char 10 of string(getAt(Hookedlines, 2))
  301.   if line2char2 = "B" then
  302.     set line2char2 to char 10 to 11 of string(getAt(Hookedlines, 2))
  303.   end if
  304.   if line2char1 <> string(HookedNum) then
  305.     set line2 to line2char1
  306.   else
  307.     set line2 to line2char2
  308.   end if
  309.   set EndlineRef to ValidLine(line1, line2)
  310.   set Snum to getaProp(getaProp(gObjects, EndlineRef), #SpriteNum)
  311.   set the visible of sprite S1 to 0
  312.   set the visible of sprite S2 to 0
  313.   set aTop to the top of sprite Snum
  314.   set aBottom to the bottom of sprite Snum
  315.   if the type of sprite Snum = 5 then
  316.     set aleft to the left of sprite Snum
  317.     set aRight to the right of sprite Snum
  318.   else
  319.     set aleft to the right of sprite Snum
  320.     set aRight to the left of sprite Snum
  321.   end if
  322.   set returnLoc to LineMove(aleft, aTop, aRight, aBottom)
  323.   CheckBassStringUP(Snum, EndlineRef, the locH of returnLoc, the locV of returnLoc)
  324. end
  325.  
  326. on ShowNewHookedLines HookedNum, lineclicked
  327.   set line1 to char 9 of string(lineclicked)
  328.   set line2 to char 10 of string(lineclicked)
  329.   if line2 = "B" then
  330.     set line2 to char 10 to 11 of string(lineclicked)
  331.   end if
  332.   set line1name to ValidLine(line1, HookedNum)
  333.   set line2name to ValidLine(line2, HookedNum)
  334.   set Line1OBj to getaProp(gObjects, line1name)
  335.   set Line2OBj to getaProp(gObjects, line2name)
  336.   set the visible of sprite getaProp(Line1OBj, #SpriteNum) to 1
  337.   set the visible of sprite getaProp(Line2OBj, #SpriteNum) to 1
  338.   set the rect of sprite getaProp(getaProp(gObjects, #BasslineFake1), #SpriteNum) to rect(-2000, -2000, -2000, -2000)
  339.   set the rect of sprite getaProp(getaProp(gObjects, #BasslineFake2), #SpriteNum) to rect(-2000, -2000, -2000, -2000)
  340.   setaProp(getaProp(Line1OBj, #SpriteProp), #visible, 1)
  341.   setaProp(getaProp(Line2OBj, #SpriteProp), #visible, 1)
  342.   MakeDynamic(line1name, #State, #visible)
  343.   MakeDynamic(line2name, #State, #visible)
  344.   setAt(getaProp(getaProp(gObjects, #BASS), #Hooked), HookedNum, [line1name, line2name])
  345. end
  346.  
  347. on ResetBassLineStart Snum, H, V
  348.   set the rect of sprite getaProp(getaProp(gObjects, #BasslineFake1), #SpriteNum) to rect(-2000, -2000, -2000, -2000)
  349.   set the rect of sprite getaProp(getaProp(gObjects, #BasslineFake2), #SpriteNum) to rect(-2000, -2000, -2000, -2000)
  350.   set the visible of sprite Snum to 1
  351.   CursorandUpdate()
  352.   set one to abs(the bottom of sprite Snum - the top of sprite Snum)
  353.   set Two to abs(the right of sprite Snum - the left of sprite Snum)
  354.   set Dis to max(list(one, Two))
  355.   set locPoint to point(H, V)
  356.   set HPoint to point(the right of sprite Snum, the bottom of sprite Snum) - locPoint
  357.   set Vpoint to point(the left of sprite Snum, the top of sprite Snum) - locPoint
  358.   set resultpoint to HPoint - Vpoint
  359.   set leng to max(list(the locV of resultpoint, the locH of resultpoint))
  360.   PlayBassNote(Dis, leng)
  361. end
  362.